//
//  RecCell.m
//  HeartTravel
//
//  Created by dlios on 15-6-30.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "RecCell.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@implementation RecCell

-(void)dealloc{
    [_authorLabel release];
    [_dataLabel release];
    [_backView release];
    [_localLabel release];
    [_timeLabel release];
    [_nameLabel release];
    [_readLabel release];
        [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatData];
    }
    return self;
}
-(void)creatData{
    self.backView=[[UIImageView alloc]init];
    [self.contentView addSubview:self.backView];
    [self.backView release];
    
    
    self.authorButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [self.backView addSubview:self.authorButton];
   
    
    self.nameLabel=[[UILabel alloc]init];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel sizeToFit];
    [self.nameLabel release];
    self.nameLabel.font=[UIFont systemFontOfSize:20];
    
    
    
    self.dataLabel=[[UILabel alloc]init];
    [self.contentView addSubview:self.dataLabel];
    [self.dataLabel release];
    
    self.timeLabel=[[UILabel alloc]init];
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel release];
    
    self.localLabel=[[UILabel alloc]init];
    [self.contentView addSubview:self.localLabel];
    [self.localLabel release];
    
    self.readLabel =[[UILabel alloc]init];
    [self.contentView addSubview:self.readLabel];
    [self.readLabel release];
    
    self.authorLabel =[[UILabel alloc]init];
    [self.contentView addSubview:self.authorLabel];
    [self.authorLabel release];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.backView.frame=CGRectMake(5, 5, WIDTH-10, HEIGHT-5);
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:20],NSFontAttributeName , nil];
    CGRect rect=[self.nameLabel.text boundingRectWithSize:CGSizeMake (375, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.nameLabel.numberOfLines=0;
    self.nameLabel.frame=CGRectMake(15,15, WIDTH-25, rect.size.height) ;
    self.nameLabel.textColor=[UIColor whiteColor];
    self.nameLabel.shadowOffset=CGSizeMake(2, 2);
    self.nameLabel.shadowColor=[UIColor grayColor];
    self.dataLabel.frame=CGRectMake(20, rect.size.height+15, 70, 15);
    self.dataLabel.font=[UIFont systemFontOfSize:12];
    self.dataLabel.textColor=[UIColor whiteColor];
    self.dataLabel.shadowColor=[UIColor grayColor];
    self.dataLabel.shadowOffset=CGSizeMake(1, 1);
    
    self.readLabel.frame=CGRectMake(130, rect.size.height+15, 80, 15);
    self.readLabel.font=[UIFont systemFontOfSize:12];
    self.readLabel.textColor=[UIColor whiteColor];
    self.readLabel.shadowOffset=CGSizeMake(1, 1);
    self.readLabel.shadowColor=[UIColor grayColor];
    
    self.timeLabel.frame=CGRectMake(90, rect.size.height+15, 40, 15);
    self.timeLabel.font=[UIFont systemFontOfSize:12];
    self.timeLabel.textColor=[UIColor whiteColor];
    self.timeLabel.shadowColor=[UIColor grayColor];
    self.timeLabel.shadowOffset=CGSizeMake(1, 1);
    
    self.localLabel.frame=CGRectMake(20, rect.size.height+35, 150, 15);
    self.localLabel.font=[UIFont systemFontOfSize:10];
    self.localLabel.textColor=[UIColor whiteColor];
    
    
    self.authorButton.frame=CGRectMake(20, HEIGHT-40, 20, 20);
    self.authorButton.layer.cornerRadius=10;
    self.authorLabel.frame=CGRectMake(60, HEIGHT-30, 100, 15);
    self.authorLabel.font=[UIFont systemFontOfSize:10];
    self.authorLabel.textColor=[UIColor whiteColor];
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
